package com.vcredit.creditcat.web.app;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vcredit.creditcat.api.ICatCardManager;
import com.vcredit.creditcat.api.ICustManager;
import com.vcredit.creditcat.dto.catCard.CatCardDto;
import com.vcredit.creditcat.dto.catCard.MyIndexCatCardDto;
import com.vcredit.creditcat.model.Cust;
import com.vcredit.creditcat.vo.JsonResult;
import com.vcredit.framework.annotation.Log;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by liaoshengjun on 2017/12/12.
 */
@RestController
@RequestMapping("/catCard")
public class CatCardController extends BaseCreditCatController{
	@Reference(version="1.0")
	private ICatCardManager catCardManager;
	@Reference(version = "1.0")
	private ICustManager custManager;

	/**
	 * 我的首页喵卡接口
	 * @param request
	 * @return
	 */
	@Log
	@RequestMapping("/myIndex")
	public JsonResult<MyIndexCatCardDto> myIndex(HttpServletRequest request){
		Cust cust = custManager.findById(super.getCust(request).getCustId());
		MyIndexCatCardDto myIndexCatCardDto=catCardManager.myIndex(cust);
		return JsonResult.SuccessResponse(myIndexCatCardDto);
	}

	/**
	 * 获取喵卡特权接口
	 * @param request
	 * @return
	 */
	@Log
	@RequestMapping("/getCatCardPrivilege")
	public JsonResult<CatCardDto> getCatCardPrivilege(HttpServletRequest request){
		Cust cust = custManager.findById(super.getCust(request).getCustId());
		CatCardDto catCardDto=catCardManager.getCatCardPrivilege(cust);
		return JsonResult.SuccessResponse(catCardDto);
	}
}
